package com.tongtong.stscommon.message;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 消息封装
 */
@Data
@ApiModel("消息封装")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class STSMessage<T> {

	@ApiModelProperty(value = "状态码")
	private int status;
	@ApiModelProperty(value = "状态信息")
	private String message;
	@ApiModelProperty(value = "返回数据")
	private T data;

	public STSMessage(int status, String message, T data) {
		this.status = status;
		this.message = message;
		this.data = data;
	}

	public static <T> STSMessage<T> from(int status, String message, T data) {
		return new STSMessage<>(status,message,data);
	}

	public static STSMessage from(int status,String message) {
		return STSMessage.from(status, message, null);
	}
}
